package com.example.demo.api.controller;

import com.example.demo.app.service.CourseService;
import com.example.demo.app.service.TeacherService;
import com.example.demo.domain.entity.Course;
import com.example.demo.domain.entity.Teacher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/course")
public class CourseController {
    @Autowired
    private CourseService courseService;
    @GetMapping("/{id}")
    public Course get(@PathVariable("id") Integer id){
        return courseService.queryCourseById(id);
    }

    @GetMapping("/list")
    public List<Course> get(){
        return courseService.queryCourseList();
    }

    @PostMapping
    public Integer add(@RequestBody Course course){
        return courseService.addCourse(course);
    }

    @PutMapping
    public Integer save(@RequestBody Course course){
        return courseService.saveCourse(course);
    }

    @PostMapping("/{id}")
    public Integer delete(@PathVariable("id") Integer id){
        return courseService.deleteCourseById(id);
    }
}
